package com.nine.controller;

import com.nine.entity.MyReturn;
import com.nine.entity.PageSort;
import com.nine.entity.TestResultFpa;
import com.nine.service.TestResultFpaService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author ：Mr.宋（mrssx@qq.com）
 * @date ：Created in 2022/6/29 20:56
 * @description：测试结果控制层
 * @modified By：
 * @version: 1.0
 */
@RestController
@RequestMapping("tsetResultFpa")
public class TestResultFpaController extends ControllerFather{
    @Autowired
    private TestResultFpaService testResultFpaService;
    MyReturn myReturn = new MyReturn();
    @RequestMapping("select.do")
    public MyReturn select(PageSort pageSort){
        Integer page = pageSort.getPage();
        int pageNew=(page-1)*pageSort.getLimit();
        pageSort.setPage(pageNew);
        List<TestResultFpa> testResultFpaList = testResultFpaService.select(pageSort);
        System.out.println(testResultFpaList.get(0).toString());
        if (testResultFpaList!=null&&testResultFpaList.size()>0){
            myReturn.setData(testResultFpaList);
            myReturn.setCount(testResultFpaService.selectCount(pageSort));
            return super.getSuccessResult(myReturn);
        }else{
            return super.getFailResult(myReturn);
        }
    }
    @RequestMapping("add.do")
    public MyReturn add(TestResultFpa testResultFpa){
            int add = testResultFpaService.add(testResultFpa);
            if (add > 0) {
                return super.getSuccessResult(myReturn);
            } else {
                return super.getFailResult(myReturn);
            }

    }
    @RequestMapping("delete.do")
    public MyReturn delete(String[] resultId){
        int delete = testResultFpaService.delete(resultId);
        if (delete>0){
            return super.getSuccessResult(myReturn);
        }else{
            return super.getFailResult(myReturn);
        }
    }
    @RequestMapping("update.do")
    public MyReturn update(TestResultFpa testResultFpa){
        int update = testResultFpaService.update(testResultFpa);
        if(update>0){
            return super.getSuccessResult(myReturn);
        }else{
            return super.getFailResult(myReturn);
        }

    }
}